package cn.cqs.redisitem.utils.redis;
/** 
 * 功能描述 :redis集群Cluster配置
 * @author cqs
 * @date 2020/9/27
 * @return * @return: null
 */

//@Configuration
public class NewRedisClientApplication {

}
/**    @Bean(name = "clusterRedisUri")
    RedisURI clusterRedisUri() {
        return RedisURI.builder()
                .withHost("127.0.0.1").withPort(7001)
                .withHost("127.0.0.1").withPort(7002)
                .withHost("127.0.0.1").withPort(7003)
                .withHost("127.0.0.1").withPort(7004)
                .withHost("127.0.0.1").withPort(7005)
                .withHost("127.0.0.1").withPort(7006).build();
    }

    //配置集群选项,自动重连,最多重定型1次
    @Bean
    ClusterClientOptions clusterClientOptions() {
        return ClusterClientOptions.builder().autoReconnect(true).maxRedirects(1).build();
    }

    //创建集群客户端
    @Bean
    RedisClusterClient redisClusterClient(ClientResources clientResources, ClusterClientOptions options, RedisURI clusterRedisUri) {
        RedisClusterClient redisClusterClient = RedisClusterClient.create(clientResources, clusterRedisUri);
        redisClusterClient.setOptions(options);
        return redisClusterClient;
    }

    //集群连接
    @Bean(destroyMethod = "close")
    StatefulRedisClusterConnection<String, String> statefulRedisClusterConnection(RedisClusterClient redisClusterClient) {
        return redisClusterClient.connect();
    }
}

*/